Conversation
|
I changed the way the variables in the configuration are set. To modify the truncation length, use import check50
check50.config.set_truncate_len(<value>)anywhere within your file, where I also modified it so that the config for The name of the function depends on the type of the default value you assign. If that default value is a For instance, to disable the dynamic truncation, use import check50
check50.config.toggle_dynamic_truncate()anywhere within your file. All configuration setter functions will be accessible under the |
|
For readability's sake, I've removed For instance, to disable the dynamic truncation, use import check50
check50.config.set_dynamic_truncate(False) |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces configurable truncation for check50 output formatting. Users can now set a custom truncation length and choose between dynamic or standard truncation modes through a configuration system.
- Adds a new Config class with validation and dynamic setter generation
- Modifies the truncation logic to respect configuration settings
- Exposes the config object through the public API
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| check50/config.py | Implements the Config class with truncation settings and dynamic setter generation |
| check50/_api.py | Updates _truncate function to use configuration values instead of hardcoded parameters |
| check50/init.py | Exports the config object to make it accessible to users |
Comments suppressed due to low confidence (1)
check50/config.py:17
- [nitpick] The variable name 'dynamic_truncate' is unclear. Based on the usage, it appears to control whether dynamic truncation is enabled. Consider renaming to 'use_dynamic_truncate' or 'enable_dynamic_truncate' for clarity.
self.dynamic_truncate = True
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
#358
put
check50.configure(truncate_len=numberhere)at top of pset's check__init__.pyfile. if configuration given, standard truncation is used where the string will just splice after numberhere # of chars. if no configuration given, automatic dynamic truncation of 10 chars is used.see ex here: https://github.com/cs50/problems/blob/test-truncation/caesar/__init__.py